package com.smf.lsc.core.respones;

import com.smf.lsc.core.respones.Result.FlagValue;

/**
 * 统一返回对象封装工具类
 * Created on 2021/11/19.
 *
 * @author ln
 * @since 1.0
 */
public class ResultUtil {

	public static Result successResult(String msg) {
		Result result = new Result();
		result.setMessage(msg);
		result.setCode(0);
		result.setFlag(FlagValue.SUCCESS);
		return result;
	}

	public static Result successResult(Object data, String msg) {
		Result result = new Result();
		result.setMessage(msg);
		result.setData(data);
		result.setCode(0);
		result.setFlag(FlagValue.SUCCESS);
		return result;
	}

	public static Result errorResult(Integer code, String msg) {
		Result result = new Result();
		result.setMessage(msg);
		result.setCode(code);
		result.setFlag(FlagValue.ERROR);
		return result;

	}
	public static Result errorResult(Integer code, String msg, Object data) {
		Result result = new Result();
		result.setMessage(msg);
		result.setData(data);
		result.setCode(code);
		result.setFlag(FlagValue.ERROR);
		return result;

	}

	public static Result warnResult(Integer code, String msg, Object data, FlagValue flag) {
		Result result = new Result();
		result.setMessage(msg);
		result.setData(data);
		result.setCode(code);
		result.setFlag(FlagValue.WARN);
		return result;
	}
}